class Set {
    constructor () {
      this.items = {}
    }
    has (element) {
      return element in this.items
    }
    add (element) {
      if (!this.has(element)) {
        this.items[element] = element
        return true
      }
      return false
    }
    delete (element) {
      if (this.has(element)) {
        delete this.items[element]
        return true
      }
      return false
    }
    clear () {
      this.items = {}
    }
    size () {
      return Object.keys(this.items).length
    }
    values () {
      return Object.values(this.items)
    }
}


function longestUniqueSubstring(s1, s2) {
  let maxLen = 0;
  let result = "";

  for (let i = 0; i < s1.length; i++) {
      const currentSet = new Set();
      let currentStr = "";

      for (let j = i; j < s1.length; j++) {
          if (currentSet.has(s1[j])) break;

          currentSet.add(s1[j]);
          currentStr += s1[j];

          if (s2.includes(currentStr) && currentStr.length > maxLen) {
              maxLen = currentStr.length;
              result = currentStr;
          }
      }
  }

  return result;
}

// 示例
console.log(longestUniqueSubstring("abcde", "abcfde")); // 输出: "abc" 或 "cde"